<template>
	<view class="content">
		<scroll-view scroll-x class="tabs-content" enable-flex scroll-with-animation>
			<view class="order-nav">
				<view class="nav-item" v-for="(nav, index) in orderState" :key="index" @tap="onNav(nav, index)">
					<view class="item-title" :class="{ 'item-title-active': tabindex === index }">{{ nav.title }}</view>
					<view class="nav-line" :class="{ 'line-active': tabindex === index }"></view>
				</view>
			</view>
		</scroll-view>

		<view class="balance-list">
			<view class="balance-item" v-for="(item, index) in blaceMoneyList" :key="index">
				<view class="balance-left">
					<view class="balance-status">{{item.service_type_name}}</view>
					<view class="balance-time">{{item.created_at}}</view>
				</view>
				<view class="balance-right">
					{{item.type == 1? '+':''}}{{item.change_money}}
				</view>
			</view>
			<view class="line"></view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tabindex: 0,
				orderState: [{
						id: 0,
						title: '全部',
					},
					{
						id: 1,
						title: '收入',
					},
					{
						id: 2,
						title: '支出',
					}
				],
				blaceMoneyList: [],
				blanceType: 0
			};
		},
		onLoad() {
			this.getUserBlaceList();
		},
		methods: {
			onNav(nav, index) {
				if (this.tabindex !== index) {
					this.tabindex = index;
					this.blanceType = index;
					this.getUserBlaceList();
				}
			},
			// 获取收入支出明细
			getUserBlaceList() {
				this.$http.get('user.getUserBlaceList', {"record_type": this.blanceType}).then(res => {
					this.blaceMoneyList = res.data.data
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	@import './balance-list.scss';
</style>
